<template>
  <div class="home">
    <!-- 1.使用差值表达式 -->
    <p>{{ $store.state.user.userMsg }}</p>
    <p>{{ $store.state.product.productMsg }}</p>
    <!-- 2.计算属性 -->
    {{ userMsg }}
  </div>
</template>

<script>
// @ is an alias to /src
// 1.先导入辅助函数
import { mapState } from 'vuex'
export default {
  name: "HomeView",
  components: {},
  mounted() {
    console.log(this.$store);
  },
  computed: {
    // userMsg() {
    //   return this.$store.state.user.userMsg;
    // }
    ...mapState('user', ['userMsg'])
    // ...mapState('user', { userMsg: state => state.userMsg })
  },
  methods: {},
};
</script>
